home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / vgagraph.zip / PALETTE.C < prev    next >
C/C++ Source or Header  |  1993-04-06  |  2KB  |  101 lines

  1. #include <dos.h>
  2.  
  3. void setpalette(int ws,char b1,char b2,char b3)
  4. {
  5.        asm{
  6.        mov ah,10h
  7.        mov al,10h
  8.        mov bx,ws
  9.        mov ch,b1
  10.        mov cl,b2
  11.        mov dh,b3
  12.        int 10h
  13.        }
  14. }
  15. void readallpalette(char pal[])
  16. {
  17. unsigned int segpal,ofspal;
  18.  
  19.       ofspal=FP_OFF(pal);
  20.       segpal=FP_SEG(pal);
  21.       asm{
  22.       mov   dx,03DAh
  23.       }
  24. SS1:  asm{
  25.       in    al,dx
  26.       test  al,8
  27.       je    SS1
  28.       mov   ax,segpal
  29.       mov   es,ax
  30.       mov   dx,ofspal
  31.       mov   bx,1
  32.       mov   cx,256
  33.       mov   ax,0x1017
  34.       int   0x10
  35.       }
  36. }
  37. void setallpalette(char pal[])
  38. {
  39. unsigned int segpal,ofspal;
  40.  
  41.       ofspal=FP_OFF(pal);
  42.       segpal=FP_SEG(pal);
  43.       asm{
  44.       push  ds
  45.       mov   dx,03DAh
  46.       }
  47. SS2:  asm{
  48.       in    al,dx
  49.       test  al,8
  50.       je    SS2
  51.       mov   dx,03C8h
  52.       mov   al,1
  53.       out   dx,al
  54.       mov   ax,segpal
  55.       mov   ds,ax
  56.       mov   si,ofspal
  57.       mov   cx,384
  58.       mov   dx,03C9h
  59.       rep   outsb
  60.       mov   cx,381
  61.       mov   dx,03DAh
  62.       }
  63. SS020:asm{
  64.       in    al,dx
  65.       test  al,8
  66.       je    SS020
  67.       mov   dx,03C9h
  68.       rep   outsb
  69.        pop   ds
  70.       }
  71. }
  72. void changepalette(char k,char palfrom[],char palto[])
  73. {
  74. int i,j,n;
  75. char pall[768];
  76. char pals[768];
  77. char  pal[768];
  78. char yes;
  79.  
  80.       for (i=0;i<768;i++) pall[i]=palfrom[i];
  81.       for (i=0;i<768;i++) pals[i]=palto[i];
  82.       for (i=0;i<768;i++) pal[i]=pall[i];
  83.       n=767;
  84. L:    yes=0;
  85.       for (i=0;i<n;i++)
  86.       {
  87.       if (pal[i]>pals[i])
  88.          {
  89.          if (pal[i]-pals[i]>k) pal[i]=pal[i]-k-1; else pal[i]=pals[i];
  90.          yes=1;
  91.          }
  92.       if (pal[i]<pals[i])
  93.          {
  94.          if (pals[i]-pal[i]>k)pal[i]=pal[i]+k+1; else pal[i]=pals[i];
  95.          yes=1;
  96.          }
  97.       }
  98.       setallpalette(pal);
  99.       if (yes==1) goto L;
  100. }
  101.